<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<form name="$ctrl.formSettings" class="gv-forms" layout="column" ng-submit="$ctrl.save()">
  <h1>Settings</h1>
  <blockquote>
    <p style="font-size: 12px">
      <ng-md-icon icon="info"  style="fill:grey;"></ng-md-icon>
      Depending on your architecture, this configuration may be overridden by a local configuration file.
      See documentation for more information.
    </p>
  </blockquote>
  <div class="gv-form">
      <h2>Company</h2>
      <div class="gv-form-content" layout="column">
          <md-input-container class="md-block" flex-gt-xs>
              <label>Company name</label>
              <input ng-model="$ctrl.settings.company.name">
          </md-input-container>
      </div>
  </div>



    <div class="gv-form">
        <h2>Management</h2>
        <div class="gv-form-content" layout="column">
            <md-input-container class="md-block" flex>
                <label>Title</label>
                <input ng-model="$ctrl.settings.management.title">
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Management URL</label>
                <input type="text" ng-model="$ctrl.settings.management.url">
            </md-input-container>
            <h6>Security plans type available</h6>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.plan.security.keyless.enabled" aria-label="A">
                    Keyless plans
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.plan.security.apikey.enabled" aria-label="A">
                    Api-key plans
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.plan.security.oauth2.enabled" aria-label="A">
                    Oauth2 plans
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.plan.security.jwt.enabled" aria-label="A">
                    JWT plans
                </md-checkbox>
            </md-input-container>

          <h6>Theme</h6>
          <md-input-container class="md-block" flex-gt-xs>
            <label>Name</label>
            <input ng-model="$ctrl.settings.theme.name">
          </md-input-container>
          <md-input-container class="md-block" flex-gt-xs>
            <label>Logo</label>
            <input ng-model="$ctrl.settings.theme.logo">
          </md-input-container>
          <md-input-container class="md-block" flex-gt-xs>
            <label>Loader</label>
            <input ng-model="$ctrl.settings.theme.loader">
          </md-input-container>
        </div>
    </div>


    <div class="gv-form">
        <h2>Portal</h2>
        <div class="gv-form-content" layout="column">

            <md-input-container class="md-block" flex-gt-xs>
                <label>Title</label>
                <input ng-model="$ctrl.settings.portal.title">
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Api-key Header
                    <small>(Used by portal to display the CURL command, change the YAML configuration to impact the gateway)</small>
                </label>
                <input ng-model="$ctrl.settings.portal.apikeyHeader">
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.apis.tilesMode.enabled" aria-label="Tiles Mode">
                    Use Tiles Mode for apis by default (if not overridden by user)
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.support.enabled" aria-label="Support">
                    Activate Support
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.rating.enabled" aria-label="Rating">
                    Activate Rating
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.rating.comment.mandatory" aria-label="Rating comment mandatory">
                    Force user to fill comment before to save a rating
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.userCreation.enabled" aria-label="Allow user creation">
                    Allow User Registration
                </md-checkbox>
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.analytics.enabled" aria-label="Add Google Analytics">
                    Add Google Analytics
                </md-checkbox>
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Google Analytics TrackingId</label>
                <input ng-model="$ctrl.settings.portal.analytics.trackingId">
            </md-input-container>
            <md-input-container class="gv-input-container-dense">
                <md-checkbox ng-model="$ctrl.settings.portal.uploadMedia.enabled" aria-label="Allow upload media">
                    Allow Upload Images
                </md-checkbox>
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Max size upload file (bytes)</label>
                <input type="number" min="0" ng-model="$ctrl.settings.portal.uploadMedia.maxSizeInOctet">
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Portal URL</label>
                <input type="text" ng-model="$ctrl.settings.portal.url">
            </md-input-container>
        </div></div>

    <div class="gv-form">
        <h2>Schedulers</h2>
        <div class="gv-form-content" layout="column">
            <md-input-container class="md-block" flex-gt-xs>
                <label>Tasks (in seconds)</label>
                <input type="number" min="0" ng-model="$ctrl.settings.scheduler.tasks">
            </md-input-container>
            <md-input-container class="md-block" flex-gt-xs>
                <label>Notifications (in seconds)</label>
                <input type="number" min="0" ng-model="$ctrl.settings.scheduler.notifications">
            </md-input-container>
        </div></div>


    <div class="gv-form">
        <h2>Documentation</h2>
        <div class="gv-form-content" layout="column">
            <md-input-container class="md-block" flex-gt-xs>
                <label>Documentation URL</label>
                <input ng-model="$ctrl.settings.documentation.url">
            </md-input-container>
        </div>
    </div>

    <div class="gv-form">
      <h2>Alerting</h2>
      <div class="gv-form-content" layout="column">
        <md-input-container class="md-block" flex-gt-xs>
          <md-checkbox ng-model="$ctrl.settings.alert.enabled" aria-label="Alerting enabled">
            Enable Alerting
          </md-checkbox>
        </md-input-container>
      </div>
    </div>

    <md-card-actions>
        <md-button type="submit" class="md-raised md-primary" ng-disabled="$ctrl.formSettings.$invalid || $ctrl.formSettings.$pristine"
                   permission permission-only="['environment-settings-c', 'environment-settings-u', 'environment-settings-d']">Save</md-button>
        <md-button type="button" class="md-raised" ng-click="$ctrl.reset()" ng-disabled="$ctrl.formSettings.$invalid || $ctrl.formSettings.$pristine"
                   permission permission-only="['environment-settings-c', 'environment-settings-u', 'environment-settings-d']">Reset</md-button>
    </md-card-actions>
</form>
